<template>
  <div id="app">
    <transition :name="transitionName">
      <div>
        <router-view class="child-view" v-wechat-title="$route.meta.title" :key="key"></router-view>
      </div>
    </transition>
  </div>
</template>

<script>
  import "babel-polyfill";
  export default {
    name: 'App',
    data(){
      return {
        transitionName: ''
      }
    },
    mounted(){

    },
    computed:{
      key(){
        return this.$route.path + Math.random();
      }
    },
    watch: {//使用watch 监听$router的变化
      $route(to, from) {
        // var a = [];
        // a = window.location.href.split('#');
        // // // console.log(a[0] + '#' +a[1])
        // var replace = a[0] + '#' +a[1];
        // // console.log(replace)
        // console.log('重定向', replace);
        // window.location.replace(encodeURIComponent(replace))
        // alert(location.href)
        // alert(to.path);
        // alert(from.path);
        // if (localStorage.getItem('token')){
        // if (to.path == '/gkx'&&localStorage.getItem('token')){
		if(this.$route.query.r){
			this.$route.query.r = '';
			console.log(898)
		}
        // }
        if (from.path == '/tel'&&to.path != '/bangding' ){
            this.$route.query.r = '';
            // if (from.path == '/tel'&&to.path != '/ge'){
            //   this.$route.go(-1);
            // }
        }
//         if(to.path == '/'||to.path =='/found'||to.path == '/ge'||to.path == '/xiaoqi'){
//           //设置动画名称
//           this.transitionName = 'slide-right';
//           // this.transitionName = '';
//         }else {
//           // setTimeout(function(){
//             this.transitionName = 'slide-left';
//           // },10000);
//         }
      }
    }
  }
</script>

<style>

    html,body{
      background: #fff;
      font-family:PingFang-SC-Bold;
    }
  .child-view {
    position: absolute;
    left: 0;
    top: 0;
    width: 7.5rem;
    height: 100%;
    background: #fff;
    font-size: 0.2rem;
    color: #000;
    transition: all .3s cubic-bezier(.55,0,.1,1);
  }
    .slide-right-leave-active{
      opacity: 0;
    }
  .slide-left-enter {
    opacity: 0;
    -webkit-transform: translate(30px, 0);
    transform: translate(30px, 0);
  }
    .slide-right-enter{
      opacity: 0;
      /*-webkit-transform: translate(-30px, 0);*/
      /*transform: translate(-30px, 0);*/
    }
  .slide-left-leave-active{
    opacity: 0;
    -webkit-transform: translate(-30px, 0);
    transform: translate(-30px, 0);
  }
</style>
